import {defineStore} from "pinia";

export const useDictStore = defineStore('sys-dict', {
    state: () => ({
        dictData: {}
    }),
    getters: {
        getDictByCode(state) {
            return (code) => state.dictData[code]
        }
    },
    actions: {
        initData(data) {
            const dictData = {}
            data.forEach(item => {
                dictData[item.code] = item.children
            })
            this.dictData = dictData
        }
    }
})